Skip to content

Add typechecking #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 24, 2025
Merged

Add typechecking #15

merged 4 commits into from
Apr 24, 2025

Conversation

nateinaction
Copy link
Member

Summary

This pull request introduces several changes to improve type safety. The most significant updates include adding type checking to the CI pipeline, refactoring code to remove unused parameters, and adding type stubs for better development support.

CI and Build Process Enhancements:

  • Added a typecheck job to the CI pipeline in .github/workflows/ci.yaml to ensure type safety using pyright.
  • Created a typecheck target in the Makefile to run type checks locally with pyright.

Code Refactoring:

  • Removed the datastore parameter from Counter and Flag instances in main.py and repl.py to simplify their initialization. [1] [2] [3]
  • Updated the spi0 variable in main.py to explicitly declare its type as SPI.
  • Removed unused method calls (f.all_face_data() and f.send_face()) in the main() function to clean up unused functionality.

Dependency and Configuration Updates:

  • Added pyright[nodejs] as a development dependency in pyproject.toml to enable type checking.
  • Configured pyright in pyproject.toml with include/exclude paths, stub paths, and module reporting options for type checking.

New Type Stubs:

  • Added a new type stub typings/board.pyi for board-specific definitions, including pin mappings and busio objects.
  • Added a new type stub typings/gc.pyi to provide type hints for the garbage collector module.

How was this tested

  • Added new unit tests
  • Ran code on hardware (screenshots are helpful)
  • Other (Please describe)
Captura de pantalla 2025-04-20 a la(s) 13 00 06

@nateinaction nateinaction requested a review from Copilot April 20, 2025 21:14
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves type safety and streamlines initialization by integrating type checking into the CI pipeline, refactoring code to remove unused parameters, and adding type stubs for enhanced development support.

  • Added a new type checking job in the CI workflow and corresponding Makefile target.
  • Removed the unused datastore parameter from Logger initializations in both main.py and repl.py.
  • Introduced type stubs in the typings directory (for the board and gc modules) and updated dependency configurations.

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
typings/gc.pyi Added type stubs for the garbage collector functionality.
typings/board.pyi Introduced board-specific type definitions and pin mappings.
repl.py Removed the unused datastore parameter from Counter usage.
pyproject.toml Added pyright dependency and configured typechecking.
main.py Updated type annotations and removed unused method calls.
.github/workflows/ci.yaml Added a new typecheck job to the CI pipeline.
Files not reviewed (1)
  • Makefile: Language not supported

@JamesDCowley JamesDCowley merged commit b6c1890 into main Apr 24, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants